const MusicHttp = require("../../utils/MusicHttp")
Page({

  data: {
    value: '',
    banner: "",
    hot: "",
    new: "",
    Dj: ""
  },
  onChange(e) {
    this.setData({
      value: e.detail,
    });
  },

  onLoad: async function (options) {
    var hotRes = await MusicHttp.getHotSong();
    this.setData({
      hot: hotRes.data.playlists.slice(0, 3)
    })

    var newRes = await MusicHttp.getNewMusic();
    this.setData({
      new: newRes.data.albums.slice(0, 3)
    })

    var djRes = await MusicHttp.getDj();
    this.setData({
      Dj: djRes.data.result.slice(0, 3)
    })

    var banner = await MusicHttp.getBanner();
    this.setData({
      banner: banner.data.banners
    })
  },
  handleHot(event) {
    var url='/top/playlist/highquality';
    wx: wx.navigateTo({
      url: `/pages/detail/detail?url=${url}`
    })
    wx.setNavigationBarTitle({
      title: '热门音乐'
    })

  },
  handleNew(event) {
    var url='/album/newest'   
    
    wx: wx.navigateTo({
      url: `/pages/detail/detail?url=${url}`
    })
    wx.setNavigationBarTitle({
      title: '最新音乐'
    })
  },
  handleDj(event) {
    var url='/personalized/djprogram'
    wx: wx.navigateTo({
      url: `/pages/detail/detail?url=${url}`
    })
    wx.setNavigationBarTitle({
      title: '主播电台'
    })
  }
})